package ModelLayer;
import java.util.ArrayList;


public class DeliveryTypes
{
    //instance variables
    private static DeliveryTypes instance = null;
    private static ArrayList<DeliveryType> deliveryTypes;
   
    /**
     * Empty constructor for testing purposes
     */
    private DeliveryTypes()
    {
       deliveryTypes = new ArrayList<DeliveryType>();
    }

    /**
     * Singleton static inplementation
     */
    
    public static DeliveryTypes getInstance()
    {
        if(instance == null)
      {
        instance = new DeliveryTypes();
      }
      return instance;
    }
   
    /**
     * Accessor and Mutator methods
     */
    
    public static void addDeliveryType(DeliveryType _deliveryType)
    {
        deliveryTypes.add(_deliveryType);
    }
    
    public static DeliveryType getDeliveryType(String _id)
    {
        DeliveryType d = new DeliveryType();
        for(int i = 0; i<deliveryTypes.size(); i++)  
        {
            if (deliveryTypes.get(i).getId().equals(_id))
                d = deliveryTypes.get(i);
        }
        return d;
    }
    
    public static void printDeliveryTypes()
    {
        System.out.println("\nDelivery Types:");
        for(int i = 0; i < deliveryTypes.size(); i++)
        {
            System.out.println("\nId: " + deliveryTypes.get(i).getId() +
                                "\nName: " + deliveryTypes.get(i).getName());
        }
        
    }
        
    public static int getSize()
    {
        return deliveryTypes.size();
    }
}